package com.ruoyi.web.controller.modules;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.modules.domain.AuditFlowLog;
import com.ruoyi.modules.service.IAuditFlowLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 申报审核日志Controller
 * 
 * @author ssh
 * @date 2024-12-15
 */
@RestController
@RequestMapping("/modules/audit/flow/log")
public class AuditFlowLogController extends BaseController
{
    @Autowired
    private IAuditFlowLogService auditFlowLogService;

    /**
     * 查询申报审核日志列表
     */
    @PreAuthorize("@ss.hasPermi('modules:auditFlowlog:list')")
    @GetMapping("/list")
    public TableDataInfo list(AuditFlowLog auditFlowLog)
    {
        startPage();
        List<AuditFlowLog> list = auditFlowLogService.selectAuditFlowLogList(auditFlowLog);
        return getDataTable(list);
    }

    /**
     * 导出申报审核日志列表
     */
    @PreAuthorize("@ss.hasPermi('modules:log:export')")
    @Log(title = "申报审核日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AuditFlowLog auditFlowLog)
    {
        List<AuditFlowLog> list = auditFlowLogService.selectAuditFlowLogList(auditFlowLog);
        ExcelUtil<AuditFlowLog> util = new ExcelUtil<AuditFlowLog>(AuditFlowLog.class);
        util.exportExcel(response, list, "申报审核日志数据");
    }

    /**
     * 获取申报审核日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('modules:log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(auditFlowLogService.selectAuditFlowLogById(id));
    }

    /**
     * 新增申报审核日志
     */
    @PreAuthorize("@ss.hasPermi('modules:log:add')")
    @Log(title = "申报审核日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AuditFlowLog auditFlowLog)
    {
        return toAjax(auditFlowLogService.insertAuditFlowLog(auditFlowLog));
    }

    /**
     * 修改申报审核日志
     */
    @PreAuthorize("@ss.hasPermi('modules:log:edit')")
    @Log(title = "申报审核日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AuditFlowLog auditFlowLog)
    {
        return toAjax(auditFlowLogService.updateAuditFlowLog(auditFlowLog));
    }

    /**
     * 删除申报审核日志
     */
    @PreAuthorize("@ss.hasPermi('modules:log:remove')")
    @Log(title = "申报审核日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(auditFlowLogService.deleteAuditFlowLogByIds(ids));
    }
}
